<?php

class ErrorTag
{
    /**
     *
     * @var FrontendApplicationContext
     */
    private $applicationContext;

    /**
     *
     * @param FrontendApplicationContext $applicationContext 
     */
    public function  __construct(FrontendApplicationContext $applicationContext)
    {
        $this->applicationContext = $applicationContext;
    }

    public function displayCode()
    {
        $exceptions = $this->applicationContext->getResponse()->getExceptions();
        $firstException = array_shift($exceptions);
        return $firstException->getCode();
    }

    /**
     *
     * @return boolean
     */
    public function evaluate()
    {
        $exceptions = $this->applicationContext->getResponse()->getExceptions();
        if (count($exceptions)) {
            return true;
        }
        return false;
    }
}